//
//  FPUserModel.h
//  FinanceProject
//
//  Created by 陈显摆 on 2025/1/15.
//

#import <UIKit/UIKit.h>
#import <CommonCrypto/CommonCryptor.h>

NS_ASSUME_NONNULL_BEGIN

@protocol FPUserCreditRecordInfo <NSObject>
@end
@interface FPUserCreditRecordInfo : JSONModel <NSCoding, NSSecureCoding>

+ (instancetype)sharedCreditRecordInfo;
/**
 *  手动保存
 */
+ (void)saveUserCreditRecordInfo:(NSArray *)list;

/**
 * 从本地获取model
 */
+ (NSArray *)getUserCreditRecordInfo;

@property (nonatomic , strong) NSString *creditLimit; //!< 授信额度
@property (nonatomic , strong) NSString *expirationTime; //!< 授信到期日期
@property (nonatomic , strong) NSString *guarantee; //!< 担保方式
@property (nonatomic , strong) NSString *ID; //!<
@property (nonatomic , strong) NSString *loanRate; //!< 贷款利率
 
@property (nonatomic , strong) NSString *startTime; //!< 授信起始日期
@property (nonatomic , strong) NSString *userId; //!<



@end








@protocol FPUserLoanInfo <NSObject>
@end
@interface FPUserLoanInfo : JSONModel <NSCoding, NSSecureCoding>

+ (instancetype)sharedUserLoanInfo;
/**
 *  手动保存
 */
+ (void)saveUserLoanInfo:(NSArray *)list;

/**
 * 从本地获取model
 */
+ (NSArray *)getUserLoanInfo;

@property (nonatomic , strong) NSString *amount; //!< 借款金额
@property (nonatomic , strong) NSString *auditPassageTime; //!< 审核通过时间
@property (nonatomic , strong) NSString *contractNumber; //!< 合同编号
@property (nonatomic , strong) NSString *createTime; //!< 创建时间
@property (nonatomic , strong) NSString *firstRepaymentDate; //!< 首期还款日期

@property (nonatomic , strong) NSString *ID; //!<
@property (nonatomic , strong) NSString *interestRate; //!< 借款利率
@property (nonatomic , strong) NSString *lastRepaymentDate; //!< 最后还款日期
@property (nonatomic , strong) NSString *lendersTime; //!< 放款日期
@property (nonatomic , strong) NSString *lengthOfMaturity; //!< 借款期限（期数）0.3个月,1.6个月,2.9个月,3.12个月,4.24个月

@property (nonatomic , strong) NSString *loanPurpose; //!< 借款用途 O代表日常消费，1代表装修，2代表教育，3代表手机数码，4代表电器，5代表其他
@property (nonatomic , strong) NSString *repaymentMethod; //!<  还款计划
@property (nonatomic , strong) NSString *status; //!<  借款状态
@property (nonatomic , strong) NSString *userBankCardId; //!< 收款账户
@property (nonatomic , strong) NSString *userId; //!<


@end









@protocol FPUserBankCardInfo <NSObject>
@end
@interface FPUserBankCardInfo : JSONModel <NSCoding, NSSecureCoding>

+ (instancetype)sharedBankCardInfo;
/**
 *  手动保存
 */
+ (void)saveUserBankCardInfo:(NSArray *)list;

/**
 * 从本地获取model
 */
+ (NSArray *)getUserBankCardInfo;

@property (nonatomic , strong) NSString *affiliation; //!< 所属银行
@property (nonatomic , strong) NSString *bankName; //!< 银行名称
@property (nonatomic , strong) NSString *cardNumber; //!< 银行卡号
@property (nonatomic , strong) NSString *cardType; //!<  银行卡类型
@property (nonatomic , strong) NSString *cardholderName; //!< 持卡人姓名

@property (nonatomic , strong) NSString *country; //!< 国家/地区
@property (nonatomic , strong) NSString *createdTime; //!< 创建时间
@property (nonatomic , strong) NSString *currency; //!< 货币类型
@property (nonatomic , strong) NSString *cvv; //!< 安全码
@property (nonatomic , strong) NSString *delFlag; //!< 删除标志（O代表未删除，1代表已删除)

@property (nonatomic , strong) NSString *expirationDate; //!< 有效期
@property (nonatomic , strong) NSString *ID; //!<
@property (nonatomic , strong) NSString *isDefault; //!< 是否默认
@property (nonatomic , strong) NSString *lastFourDigits; //!< 最后四位数字
@property (nonatomic , strong) NSString *openBank; //!< 开户银行

@property (nonatomic , strong) NSString *phone; //!< 手机号码
@property (nonatomic , strong) NSString *status; //!< 状态
@property (nonatomic , strong) NSString *updatedTime; //!< 更新时间
@property (nonatomic , strong) NSString *userId; //!<




@end


@protocol FPProducts <NSObject>
@end
@interface FPProducts : JSONModel

@property (nonatomic , strong) NSString *advertId;
@property (nonatomic , strong) NSString *annualInterestRate;
@property (nonatomic , strong) NSString *auth;
@property (nonatomic , strong) NSString *companyId;
@property (nonatomic , strong) NSString *companyName;

@property (nonatomic , strong) NSString *cooperateName;
@property (nonatomic , strong) NSString *h5Url;
@property (nonatomic , strong) NSString *loanAmount;
@property (nonatomic , strong) NSString *price;
@property (nonatomic , strong) NSString *productLogo;

@property (nonatomic , strong) NSString *productName;
@property (nonatomic , strong) NSString *sameIndustryStatus;
@property (nonatomic , strong) NSString *sellingPoint;
@property (nonatomic , strong) NSString *sourceType;
@property (nonatomic , strong) NSString *url;

@property (nonatomic , assign) BOOL isSelect;

+ (instancetype)sharedProducts;
 
@end





/**
 *  User存储类
 */
@interface FPUserInfoModel : JSONModel <NSCoding, NSSecureCoding>


@property (nonatomic , strong) NSString *age; //!< 年龄
@property (nonatomic , strong) NSString *alipaySesamePoint; //!<  0.无芝麻分,1.600分以下,2.600-650分,3.650-700分,4.700分以上)
@property (nonatomic , strong) NSString *auditStatus; //!< 授信审核状态（0代表未审核，1代表审核中，2代表审核通过，3代表审核未通过）
@property (nonatomic , strong) NSString *avatar; //!< 头像
@property (nonatomic , strong) NSString *carModel; //!< 车辆型号

@property (nonatomic , strong) NSString *carProve; //!< 上传行驶证
@property (nonatomic , strong) NSString *companyAddress; //!< 公司地址
@property (nonatomic , strong) NSString *companyDetailsAddress; //!< 公司详情地址
@property (nonatomic , strong) NSString *companyName; //!< 公司名称
@property (nonatomic , strong) NSString *createTime; //!< 创建时间

@property (nonatomic , strong) NSString *creditCardDebt; //!< 信用卡欠款（0.无欠款,1.1000元以下,2.1000-3000元,3.3000-5000元,4.5000-10000元,5.10000元-50000元,6.50000元以上
@property (nonatomic , strong) NSArray <FPUserCreditRecordInfo> *creditRecord; //!< 授信记录表 array
@property (nonatomic , strong) NSString *creditStatus; //!< 征信审核状态（0代表未通过，1代表通过）
@property (nonatomic , strong) NSString *delFlag; //!< 删除标志（0代表正常，1代表已删除，2代表禁用）)
@property (nonatomic , strong) NSString *deviceType; //!< 设备类型（0代表安卓 1代表ios 2代表其他）

@property (nonatomic , strong) NSString *educationalAttainment; //!< 教育程度（1小学，2初中，3高中，4大专，5本科，6硕士，7博士)
@property (nonatomic , strong) NSString *email; //!< 邮箱
@property (nonatomic , strong) NSString *houseProve; //!< 上传房产证
@property (nonatomic , strong) NSString *ID; //!< 用户ID
@property (nonatomic , strong) NSString *idCardImageFront; //!< 身份证正面

@property (nonatomic , strong) NSString *idCardImageReverseSide; //!< 身份证反面
@property (nonatomic , strong) NSString *idCardVerify; //!< 是否验证身份证（0表示未验证，1表示验证通过）
@property (nonatomic , strong) NSString *idcardName; //!< 身份证姓名
@property (nonatomic , strong) NSString *idcardNumber; //!< 身份证号码
@property (nonatomic , strong) NSString *incomeProve; //!< 上传收入凭证

@property (nonatomic , strong) NSString *infoStatus; //!< 资料审核状态（0填写中，1填写完成）
@property (nonatomic , strong) NSString *isCar; //!< 是否有车（0代表没有，1代表有
@property (nonatomic , strong) NSString *isHouse; //!<  是否有房（0代表没有，1代表有
@property (nonatomic , strong) NSString *lengthOfEmployment; //!< 在职时长
@property (nonatomic , strong) NSArray <FPUserLoanInfo> *loan; //!< 贷款记录表 array

@property (nonatomic , strong) NSString *loanAmount; //!< 贷款额度
@property (nonatomic , strong) NSString *maritalStatus; //!< 婚姻状况（O代表未婚，1代表已婚，2代表离异)
@property (nonatomic , strong) NSString *mobileModel; //!< 手机型号
@property (nonatomic , strong) NSString *monthlyIncome; //!< 平均月收入（1代表3000元以下，2代表3000-4000元，3代表4000-6000元，4代表6000-8000元，5代表8000-12000元，6代表12000-18000元，7代表18000元以上)
@property (nonatomic , strong) NSString *occupation; //!< 职位

@property (nonatomic , strong) NSString *occupationType; //!< 职业类型（1.国家机关、党群组织、企业、事业单位负责人，2.专业技术人员，3.办事人员和有关人员，4.商业、服务业人员，5.农、林、牧、渔、水利业生产人员，6.生产、运输设备操作人员及有关人员,7.军人,8不便分类的其他从业人员)
@property (nonatomic , strong) NSString *otherDebt; //!< 其他欠款（0.无欠款,1.1000元以下,2.1000-3000元,3.3000-5000元,4.5000-10000元,5.10000元-50000元,6.50000元以上）
@property (nonatomic , strong) NSString *password; //!< 密码
@property (nonatomic , strong) NSString *phone; //!< 手机号
@property (nonatomic , strong) NSString *placeResidence; //!< 居住地址
 
@property (nonatomic , strong) NSString *providentFundBalance; //!< 公积金个账余额
@property (nonatomic , strong) NSString *providentFundBalanceProve; //!< 上传公积金个账余额凭证
@property (nonatomic , strong) NSString *providentFundBase; //!< 公积金缴纳基数
@property (nonatomic , strong) NSString *providentFundMonth; //!< 公积金连缴月份
@property (nonatomic , strong) NSString *providentFundProve; //!< 上传公积金缴纳凭证

@property (nonatomic , strong) NSString *providentFundRatio; //!< 公积金缴纳比例
@property (nonatomic , strong) NSString *residentialDetailsAddress; //!< 居住详情地址
@property (nonatomic , strong) NSString *sesamePointProve; //!< 上传芝麻分凭证
@property (nonatomic , strong) NSString *sex; //!< 用户性别（0男，1女，2未知)
@property (nonatomic , strong) NSString *socialSecurityBase; //!<  社保缴纳基数

@property (nonatomic , strong) NSString *socialSecurityMonth; //!< 社保连缴月份
@property (nonatomic , strong) NSString *socialSecurityProve; //!< 上传社保缴纳凭证
@property (nonatomic , strong) NSString *status; //!< 账号状态(0正常1停用)
@property (nonatomic , strong) NSString *storageType; //!< 入库类型（1首次入库，2资料补充
@property (nonatomic , strong) NSString *typeHousing; //!< 住房类型（0代表租房，1代表商品房，2代表自建房)

@property (nonatomic , strong) NSString *updateBy; //!< 更新人
@property (nonatomic , strong) NSString *updateTime; //!< 更新时间
@property (nonatomic , strong) NSArray <FPUserBankCardInfo> *userBankCard; //!< 银行卡信息表    array
@property (nonatomic , strong) NSString *userName; //!< 用户名
@property (nonatomic , strong) NSString *channel;

@property (nonatomic , strong) NSString *accompanyUrl;
@property (nonatomic , strong) NSString *accumulationFund;
@property (nonatomic , strong) NSString *address;
@property (nonatomic , strong) NSString *alyUrl;
@property (nonatomic , strong) NSString *baseMax;

@property (nonatomic , strong) NSString *baseMin;
@property (nonatomic , strong) NSString *callerLoc;
@property (nonatomic , strong) NSString *city;
@property (nonatomic , strong) NSString *commercialInsurance;
@property (nonatomic , strong) NSString *customerName;

@property (nonatomic , strong) NSString *creditAdjustment;
@property (nonatomic , strong) NSString *creditCardAmount;
@property (nonatomic , strong) NSString *creditCardLimit;
@property (nonatomic , strong) NSString *customerPhone;
@property (nonatomic , strong) NSString *customerSourceType;

@property (nonatomic , strong) NSString *customerStart;
@property (nonatomic , strong) NSString *entrepreneurLicense;
@property (nonatomic , strong) NSString *existRoom;
@property (nonatomic , strong) NSString *identify;
@property (nonatomic , strong) NSString *individualLicense;

@property (nonatomic , strong) NSString *ip;
@property (nonatomic , strong) NSString *lengthOfMaturity;
@property (nonatomic , strong) NSString *mask;
@property (nonatomic , strong) NSString *location;
@property (nonatomic , strong) NSString *monthlyInvoicingRevenue;

@property (nonatomic , strong) NSString *monthlyOperatingFlow;
@property (nonatomic , strong) NSString *phoneMask10;
@property (nonatomic , strong) NSString *phoneMask7;
@property (nonatomic , strong) NSString *phoneMask8;
@property (nonatomic , strong) NSString *phoneMask9;

@property (nonatomic , strong) NSString *phoneMd5;
@property (nonatomic , strong) NSString *phoneStatus;
@property (nonatomic , strong) NSString *sesameSeeds;
@property (nonatomic , strong) NSString *socialSecurity;
@property (nonatomic , strong) NSString *sourceOfClue;

@property (nonatomic , strong) NSString *totalCredit;
@property (nonatomic , strong) NSString *type;
@property (nonatomic , strong) NSString *usageOfLoan;
@property (nonatomic , strong) NSString *userId;
@property (nonatomic , strong) NSString *vehicleCondition;

@property (nonatomic , strong) NSString *wechat;

@property (nonatomic , assign) BOOL succeed;
@property (nonatomic , strong) NSArray <FPProducts> *products;
@property (nonatomic , strong) NSString *customerId;
@property (nonatomic , strong) NSString *requestId;
@property (nonatomic , strong) NSString *provinceName;
@property (nonatomic , strong) NSString *cityName;

//@property (nonatomic,strong) NSString *auditStatus; //!< （0代表未审核，1代表审核中，2代表审核通过，3代表审核未通过）
//@property (nonatomic,strong) NSString *avatar;
//@property (nonatomic,strong) NSString *companyAddress;
//@property (nonatomic,strong) NSString *companyDetailsAddress;
//@property (nonatomic,strong) NSString *companyName;
//
//@property (nonatomic,strong) NSString *educationalAttainment;
//@property (nonatomic,strong) NSString *email;
//@property (nonatomic,strong) NSString *ID;
//@property (nonatomic,strong) NSString *idCardImageFront;
//@property (nonatomic,strong) NSString *idCardImageReverseSide;
//
//@property (nonatomic,strong) NSString *idcardName;
//@property (nonatomic,strong) NSString *idcardNumber;
//@property (nonatomic,strong) NSString *maritalStatus;
//@property (nonatomic,strong) NSString *monthlyIncome;
//@property (nonatomic,strong) NSString *occupation;
//
//@property (nonatomic , strong) NSString *phone;
//@property (nonatomic , strong) NSString *placeResidence; //!< 居住地址
//@property (nonatomic , strong) NSString *residentialDetailsAddress; //!< 居住详情地址
//@property (nonatomic , strong) NSString *sex;
//@property (nonatomic , strong) NSString *typeHousing;
//
//@property (nonatomic , strong) NSString *userName;
@property (nonatomic , strong) NSString *customerContact; //!< 客服电话 个人中心


+ (instancetype)sharedUserInfo;

- (NSDictionary<NSString *, NSString *> *)getAllPropertiesWithTypes;
- (NSArray<NSString *> *)getAllProperties;

/**
 *  获取用户信息
 */
+ (void)getUserInfoWithSuccess:(void (^)(FPUserInfoModel *model))success failure:(void (^)(NSError *error))failure;

/**
 *  上传用户信息
 */
+ (void)updateUserInfoWithParam:(NSDictionary *)param success:(void (^)(NSString *msg, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 *  用户留资修改
 */
+ (void)updateAdvertUserInfoWithParam:(NSDictionary *)param success:(void (^)(NSString *msg, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 *  手动保存用户信息
 */
+ (void)saveUserInfo:(FPUserInfoModel *)model;

+ (void)checkUserProfileInfoSuccess:(void (^)(NSInteger code , NSString *message , FPUserInfoModel *userInfoModel))success failure:(void (^)(NSError *error))failure;

+ (void)checkMatchProductsParam:(FPUserInfoModel *)userInfo isHome:(BOOL)isHome success:(void (^)(NSInteger code , NSString *message , FPUserInfoModel *infoModel))success failure:(void (^)(NSError *error))failure;
/**
 *  留资后 服务端查询数据使用
 */
+ (void)outPushWithParam:(NSDictionary *)param success:(void (^)(NSString *msg, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 * 判断是否为真实用户
 */
+ (void)outIdWithParam:(NSDictionary *)param success:(void (^)(NSString *webUrl, NSString *msg, NSInteger code))success failure:(void (^)(NSError *error))failure;
@end




/**
 *  User工具类
 */
@interface FPUserModel : JSONModel <NSCoding, NSSecureCoding>

@property (nonatomic , strong) NSString *token;
@property (nonatomic , strong) NSString *headUrl;
@property (nonatomic , assign) BOOL registered;


/**
 *  活体检测 获取token  FinAuth
 */
+ (void)getFinAuthFaceTokenSuccess:(void (^)(NSInteger code , NSString *message , NSString *token , NSString *province , NSString *cityName , NSString *cityID))success failure:(void (^)(NSError *error))failure;


/**
 *  版本检测
 */
+ (void)getApplicationVersionInfoSuccess:(void (^)(NSString * _Nonnull version, NSInteger code, NSString * _Nonnull updateURL , NSString * _Nonnull manualURL , NSString * _Nonnull appSize , NSArray * _Nonnull content , BOOL isForce))success failure:(void (^)(NSError *error))failure;

/**
 *  极光登录
 */
//+ (void)JGLoginWithParam:(NSMutableDictionary *)param success:(void (^)(FPUserModel *model, NSString *message, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 *  验证码登录
 */
+ (void)loginWithPhoneNumber:(NSString *)phoneNumger code:(NSString *)code success:(void (^)(FPUserModel *model, NSString *message, NSInteger code , BOOL firstRegist))success failure:(void (^)(NSError *error))failure;

/**
 *  获取验证码
 */
+ (void)getMessageCodeWithPhoneNumber:(NSString *)phoneNumber success:(void (^)(BOOL isSuccess, NSString *message, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 *  阿里一键登录token 传给后端
 */
+ (void)loginWithAccessToken:(NSString *)token success:(void (^)(NSString *message, NSInteger code , BOOL firstRegist))success failure:(void (^)(NSError *error))failure;

/**
 *  在验证码次数上限后 会进行人机识别验证 验证通过之后调用一次这个接口 再重新获取验证码(getMessageCodeWithPhoneNumber)
 */
//+ (void)refreshMessageCodeSuccess:(void (^)(NSInteger code, NSString *message))success failure:(void (^)(NSError *error))failure;


/**
 *  退出登录
 */
+ (void)logoutSuccess:(void (^)(NSString *message, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 *  注销账号
 */
+ (void)clearAccountWithID:(NSString *)userID success:(void (^)(NSString *message, NSInteger code))success failure:(void (^)(NSError *error))failure;

/**
 *  实例化API
 */
+ (instancetype)sharedUser;


/**
 *  人脸认证
 */
+ (void)faceAuthenticationWithParam:(NSDictionary *)param success:(void (^)(NSString *message, NSInteger code , NSString *faceUrl ,  NSInteger result, NSString *serialNo, NSString *serialVersionUID, NSString *type))success failure:(void (^)(NSError *error))failure;

/**
 *  实名认证结果查询
 */
+ (void)realNameAuthResultWithParam:(NSDictionary *)param success:(void (^)(NSString *message, NSInteger code,NSInteger result))success failure:(void (^)(NSError *error))failure;
/**
 *  提交意见反馈
 */
+ (void)submitFeedBackWithParam:(NSDictionary *)param success:(void (^)(NSInteger code , NSString *message))success failure:(void (^)(NSError *error))failure;

/**
 *  获取服务器当前时间
 */
+ (void)getServiceCurrenTimeSuccess:(void (^)(NSInteger code , NSString *message , NSString *currenTime))success failure:(void (^)(NSError *error))failure;


/**
 * 获取保存的 token
 */
+ (NSString *)globalToken;

+ (void)setUserToken:(NSString *)token;

+ (void)removeToken;

+ (void)setHeadURL:(NSString *)headURL;

+ (NSString *)globalHeadURL;

+ (BOOL)firstRegisterUser;

+ (void)setFirstRegisterUser:(BOOL)firstRegister;

/**
 * 从本地获取model
 */
+ (FPUserInfoModel *)getUserInfoModel;

/**
 *  登录失效
 */
- (void)loginInvalid;

/**
 * 解密
 */
+ (NSString *)AES256Decrypt:(NSString *)text;

/**
 * 加密
 */
+ (NSString *)AES256Encrypt:(NSString *)text;



@end

NS_ASSUME_NONNULL_END
